package com.xr.pfm.template;

import com.xr.common.CommUtil;
import com.bstek.dorado.common.*;
import com.bstek.dorado.data.*;
import com.bstek.dorado.data.db.DBStatement;
import com.bstek.dorado.view.*;
import com.bstek.dorado.view.data.*;
import com.bstek.dorado.view.control.*;

/**
 * formViewModel
 */
public class formViewModel extends DefaultViewModel {
  protected void doUpdateData(ParameterSet parameters, ParameterSet outParameters)
      throws Exception {
	  Dataset dsTemplate=getDataset("datasetList");
	  Dataset dsPfm=getDataset("datasetPfm");
	  DBStatement dbs =new DBStatement();
      CommUtil.dbsUpdateData(dbs, dsTemplate, "PFM_TEMPLATE", "PFM_TEMPLATE_ID");
      dsPfm.moveFirst();
      while(!dsPfm.isLast()){
    	  dsPfm.setValue("PFM_TEMPLATE_ID", dsTemplate.getString("PFM_TEMPLATE_ID"));
    	  dsPfm.moveNext();
      }
      CommUtil.dbsUpdateData(dbs, dsPfm, "PFM_TEMPLATE_ITEM_DEMO", "PFM_TEMPLATE_ITEM_ID");
      dbs.close();
      
      RecordIterator ri = dsPfm.recordIterator();
      ri.setVisibility(Dataset.FILTER_DELETED);
      while (ri.hasNext()) {
        Record record = ri.nextRecord();
        CommUtil.executeUpdate(dbs,"delete from PFM_TEMPLATE_ITEM_DEMO where PFM_TEMPLATE_ITEM_ID="+record.getString("PFM_TEMPLATE_ITEM_ID"));
      }
      
      dbs.close();
      
      outParameters.setValue("OUTP_PFM_RESULT_ID", dsTemplate.getString("PFM_TEMPLATE_ID"));
      
      
      
    //super.doUpdateData(parameters, outParameters);
  }

}
